package org.an.proj.contacts.net.service.rx;

import android.support.annotation.Nullable;
import org.an.proj.contacts.model.response.Result;
import rx.Subscriber;

/**
 * 我们更希望统一处理结果，所有将onError和onNext统一处理
 * {@link Result} 处理Result的简易Subscriber
 * Created by an on 2016/12/26.<br/>
 */

public abstract class ResultSubscriber<T> extends Subscriber<Result<T>> {
  @Override public void onCompleted() {

  }

  @Override public void onError(Throwable e) {
    onResponse(null, e);
  }

  @Override public void onNext(Result<T> result) {
    onResponse(result, null);
  }

  //public abstract void onResponse(Result<T> result);

  public abstract void onResponse(Result<T> result, @Nullable Throwable error);
}
